<!--  -->
<template>
  <div class="comment">
    <template v-if="commentList.length==0">
      <div class="empty flex justify-center aligin-center">
        <span class="empty-icon"></span>
      </div>
    </template>
    <template v-else>
      <template v-for="(item,index) in commentList">
        <div class="comment-item" :key="index">
          <div>
            <img class="avatar" :src="item.user_headimg" alt="">
            <span class="ml-6 mt-8 f-12 f-medium">{{item.member_name}}</span>
          </div>
          <div class="img-wrapper flex" v-if="item.image&&item.image.length">
            <template v-for="(item,index) in item.image">
              <img :key="index" class="img mr-8" :src="item" alt="" @click="preview(item)">
            </template>
          </div>
          <div class="f-12 content ellipsis-line2">{{item.content}}</div>
        </div>
      </template>
    </template>
  </div>
</template>

<script>
import { ImagePreview } from "vant";
export default {
  components: {},
  props: {
    commentList: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {
    preview(url) {
      ImagePreview([url]);
    }
  },
  created() {},
  mounted() {},
  updated() {}, //生命周期 - 更新之后
  destroyed() {} //生命周期 - 销毁完成
};
</script>
<style lang='less' scoped>
//@import url(); 引入公共css类
.comment {
  height: 100%;
  .empty {
    height: 190px;
  }
  .empty-icon {
    height: 80px;
    width: 80px;
    background: url("../assets/imgs/empty-comment.png");
    background-size: 100% 100%;
  }
  .comment-item {
    padding: 14px 16px 20px;
    box-sizing: border-box;
    .avatar {
      height: 25px;
      width: 25px;
      border-radius: 50%;
    }
    .content {
      height: 36px;
      line-height: 18px;
    }
  }
  .img-wrapper {
    padding: 15px 0;
    .img {
      width: 60px;
      height: 60px;
      border-radius: 3px;
    }
  }
}
/*滚动条整体样式*/
.comment::-webkit-scrollbar {
  width: 3px;
  height: 1px;
}
/*滚动条滑块*/
.comment::-webkit-scrollbar-thumb {
  border-radius: 10px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(254, 114, 123, 1);
}
/*滚动条轨道*/
.comment::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 1px rgba(0, 0, 0, 0);
  border-radius: 10px;
  background: #fff;
}
</style>